<cfcomponent>
   	<cffunction name="createit" access="public" returntype="array" description="Creates a captcha string.  Returns an array with string and encrypted string.">
    <cfargument default="3" required="no" name="characters" type="numeric" hint="Number of characters to use for captcha">
        <cfset arrValidChars = ListToArray("a,b,c,d,e,f,g,h,j,k,m,n,p,r,s,t,u,v,w,x,y,z," & "2,3,4,5,6,7,8,9" ) />
        <cfset CreateObject("java", "java.util.Collections").Shuffle(arrValidChars) />
        <cfset mystrCaptcha = "">
        
        <cfloop from = "1" to = "#characters#" index="i">
			<cfset mystrCaptcha = mystrCaptcha & (arrValidChars[ #i# ])>
        </cfloop>
		
        <cfinvoke component="encryption" method="encryptstring" textstring="#mystrCaptcha#" returnvariable="enc_captcha">
        
        <cfset strCaptcha = ArrayNew(1)>
        <cfset arrayappend(strCaptcha, mystrCaptcha)>
        <cfset arrayappend(strCaptcha, enc_captcha)>

        <cfreturn strCaptcha>
    </cffunction>
    
    <cffunction name="compareit" access="public" returntype="string" description="Compares a string with that of an encrypted string, needs request.seedstring set.  Returns 1 if passed 0 if failed.">
	    <cfargument required="yes" name="textstring" type="string" hint="Plane text string of characters passed from a form field.">
	    <cfargument required="yes" name="encstring" type="string" hint="The encrypted string to compare it to.">

		<cfinvoke component="encryption" method="encryptstring" textstring="#textstring#" returnvariable="compare_encstring">
        <cfif compare_encstring IS encstring>
            <cfset captchapassed = 1>
        <cfelse>
            <cfset captchapassed = 0>
        </cfif>
        
        <cfreturn captchapassed>
    </cffunction>
</cfcomponent>